#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author: nigo
import plotly.graph_objects as go
# 数据
labels = ['人工', '制造费用', '原材料', '住房公积金', '养老保险', '医疗保险', 
          '工资', '办公费', '折旧', '水', '电', '物料1', '物料2', '物料3']
parents = ['', '', '', '人工', '人工', '人工', '人工', '制造费用', '制造费用', 
           '制造费用', '制造费用', '原材料', '原材料', '原材料']
values = [2630000.0, 580000.0, 11000000.0, 10000.0, 100000.0, 20000.0, 2500000.0, 
          50000.0, 100000.0, 30000.0, 400000.0,1000000.0, 2000000.0, 8000000.0]

# 轨迹
sunburst = go.Sunburst(labels=labels,parents=parents,values=values)
# 画布
fig = go.Figure(sunburst)
# 更新轨迹 文本为value+label
fig.update_traces(textinfo='value+label')
# fig.update_traces(branchvalues='total')
# 显示画布
fig.show()
